import axios from 'axios';

axios.defaults.timeout = 500000;

/**
 * 封装get方法
 * @param url
 * @param data
 * @returns {Promise}
 */

export function get(url,params={},head){
  return new Promise((resolve,reject) => {
    axios.get(url,{
      params:params
    },
    head
    ).then(response => {
      resolve(response.data);
    })
    .catch(err => {
      reject(err)
    })
  })
}


/**
 * 封装post请求
 * @param url
 * @param data
 * @returns {Promise}
 */

export function post(url,data = {},head){
   return new Promise((resolve,reject) => {
    axios.post(url,data,
      head
      ).then(response => {
        resolve(response.data);
      },err => {
        reject(err)
      })
   })
 }
